<?php require_once 'Master_controller.php';
class News extends Master_controller {
	protected $_page_uri = "news";
	
	function __construct() {
		parent::__construct();
		$this->view_data['active_news'] = "current";
		$this->load->model('News_model');
		$this->_page_uri = site_url() . $this->_page_uri;
	}
	
	function index($offset = 0) {
		$this->view_data['view'] = "news_view";
		$this->view_data['list_news'] = $this->News_model->get_paged_list(NEWS_ITEM_PER_PAGE, $offset)->result();
		$this->view_data['pagination'] = $this->_render_paging($this->News_model->count_all(), $offset, NEWS_ITEM_PER_PAGE);
		
		$this->render_page($this->view_data);
	}
	function detail($id = 0) {
		$this->view_data['view'] = "news_detail_view";
		$news_detail = $this->News_model->get_by_id($id)->row();
		$this->view_data['news_detail'] = $news_detail;
		$this->view_data['related_news'] = $this->News_model->get_related_list(NEWS_ITEM_PER_PAGE, 0, $news_detail->tag)->result();
		
		$this->render_page($this->view_data);
	}
}